﻿using System;
using System.Web;
using System.Web.Mvc;
using Zhang.key;

namespace Zhang.DeskTop.Controllers.Login
{
    public class RegisterController : Controller
    {
        [HttpGet]
        // GET: Register
        public ActionResult Index(string redirect = "/Home/")
        {
            HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["UC_USER_ID"];
            if ((cookie != null && cookie["user"] != "0") && Session[SessionKey.UC_USER_INFORMATION] != null)
            {
                //ShowInfo("您已登录，不用重复登录");
                return Redirect("/");
            }
            if (redirect.IndexOf("/Register", StringComparison.Ordinal) > -1)
            {
                return Redirect("/");
            }
            ViewBag.Redirect = redirect;
            return View();
        }
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Index(Model.UCenter.Login model)
        {
            var msg = new  Zhang.BLL.UCenter.Login.Login().Register(model);

            return Json(new { Code = msg.Status, Message = msg.Message }, JsonRequestBehavior.AllowGet);
        }

    }
}